<?php
namespace app\api\controller;
use app\Request;
use app\api\service\Product as ServiceProduct;
use think\facade\Cache;

class Product
{
    public function list(Request $request)
    {
        $a=new ServiceProduct();
        $where='';
        $page=$request->param('page');
        $chlist=Cache::get('prodlist'.$page);
        if(!$chlist)
        {
            $list=($a)->getPageData($page,15,$where);
            Cache::set('prodlist'.$page,$list,60);
            $chlist=$list;
        }
        return success($chlist);
    }
    public function getinfo($id)
    {
        $chres=cache('prodinfo'.$id);
        if(!$chres)
        {
            $res=(new ServiceProduct())->readByID($id);
            $chres=$res;
            Cache::set('prodinfo'.$id,$res,160);
        }
       return success($chres);
    }
}
